package top.heliming.youyou.item.api;

import java.util.List;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import top.heliming.youyou.common.pojo.PageResult;
import top.heliming.youyou.item.pojo.Sku;
import top.heliming.youyou.item.pojo.Spu;
import top.heliming.youyou.item.pojo.SpuBo;
import top.heliming.youyou.item.pojo.SpuDetail;

/**
 * description: //TODO
 *
 * @author: heliming
 * @date:2019/06/01 下午 5:16
 */
public interface GoodsApi {

  /**
   * 分页查询商品
   * @param page
   * @param rows
   * @param saleable
   * @param key
   * @return
   */
  @GetMapping("/spu/page")
  PageResult<SpuBo> querySpuByPage(
      @RequestParam(value = "page", defaultValue = "1") Integer page,
      @RequestParam(value = "rows", defaultValue = "5") Integer rows,
      @RequestParam(value = "saleable", defaultValue = "true") Boolean saleable,
      @RequestParam(value = "key", required = false) String key);

  /**
   * 根据spu商品id查询详情
   * @param id
   * @return
   */
  @GetMapping("/spu/detail/{id}")
  SpuDetail querySpuDetailById(@PathVariable("id") Long id);

  /**
   * 根据spu的id查询sku
   * @param id
   * @return
   */
  @GetMapping("sku/list")
  List<Sku> querySkuBySpuId(@RequestParam("id") Long id);

  /**
   * 根据spu的id查询spu
   * @param id
   * @return
   */
  @GetMapping("spu/{id}")
  public Spu querySpuById(@PathVariable("id") Long id);

  @GetMapping("sku/{id}")
  public ResponseEntity<Sku> querySkuById(@PathVariable("id")Long id);
}

